package com.margo.project.cors.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.cors.model.MargoCorsVO;


@Controller
@RequestMapping("/cors")
public class MargoCorsController {
	
	private Logger logger=LoggerFactory.getLogger(this.getClass());

	/**
	 * 
	 * @param margoCorsVO
	 * @return
	 */
	@PostMapping("form")
	@ResponseBody
	public String form(MargoCorsVO margoCorsVO) {
		return "ok";
	}
	
	/**
	 * 
	 * @param margoCorsVO
	 * @return
	 */
	@PostMapping("/json")
	@ResponseBody
	public String json(@RequestBody MargoCorsVO margoCorsVO){
		return "ok";
	}
	
	/**
	 * 
	 * @param margoCorsVO
	 * @return
	 */
	@PostMapping("form2")
	@ResponseBody
	public String form(HttpServletRequest request,MargoCorsVO margoCorsVO) {
		logger.info("access-token:"+request.getHeader("access-token"));
		return "ok";
	}
	
	/**
	 * 
	 * @param margoCorsVO
	 * @return
	 */
	@PostMapping("/json2")
	@ResponseBody
	public String json(HttpServletRequest request,@RequestBody MargoCorsVO margoCorsVO){
		logger.info("access-token:"+request.getHeader("access-token"));
		return "ok";
	}
}
